package com.xb.page;

import java.io.Serializable;
import java.util.List;

public class PageBean<T> implements Serializable {

    private Integer startIndex;//起始位置
    private Integer pageCount;//每页条数
    private Integer pageNumber;//第几页
    private Integer totalPage;//共几页
    private Long totalCount;//总共条数
    private List<T> list;//数据数组

    public Integer getStartIndex() {
        return (pageNumber-1)*pageCount;
    }

    public void setStartIndex(Integer startIndex) {
        this.startIndex = startIndex;
    }

    public Integer getPageCount() {
        return pageCount;
    }

    public void setPageCount(Integer pageCount) {
        this.pageCount = pageCount;
    }

    public Integer getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public long getTotalPage() {
        return totalCount%pageCount ==0?totalCount/pageCount:totalCount/pageCount+1;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Long totalCount) {
        this.totalCount = totalCount;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public PageBean(Integer startIndex, Integer pageCount, Integer pageNumber, Integer totalPage, Long totalCount, List<T> list) {
        this.startIndex = startIndex;
        this.pageCount = pageCount;
        this.pageNumber = pageNumber;
        this.totalPage = totalPage;
        this.totalCount = totalCount;
        this.list = list;
    }

    public PageBean() {
    }
}
